﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LinQ_DTO;
//MinhKhoa
namespace DAO
{
    public class TrangTriDAO
    {
        public List<shop_trangtri> LayTatCaTrangTri()
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            var products = from a in EFashionDB.shop_trangtris select a;
            return products.ToList();
        }
        public void ThemTrangTri(shop_trangtri AddObject)
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            EFashionDB.shop_trangtris.InsertOnSubmit(AddObject);
            EFashionDB.SubmitChanges();
        }
        public void XoaTrangTri(int Ma)
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            var ListResultQuery = from a in EFashionDB.shop_trangtris
                                  where a.MaTrangTri == Ma
                                  select a;
            shop_trangtri Result = ListResultQuery.Single();
            EFashionDB.shop_trangtris.DeleteOnSubmit(Result);
            EFashionDB.SubmitChanges();
        }
        public void CapNhatTrangTri(int Ma, shop_trangtri EditObject)
        {
            EFashionDBDataContext EFashionDB = new EFashionDBDataContext();
            var ListResultQuery = from a in EFashionDB.shop_trangtris
                                  where a.MaTrangTri == Ma
                                  select a;
            shop_trangtri Result = ListResultQuery.Single();

            Result.GiaTien = EditObject.GiaTien;
            Result.HinhAnh= EditObject.HinhAnh;
            Result.MaLoaiTrangTri = EditObject.MaLoaiTrangTri;
            EFashionDB.SubmitChanges();
        }
    }
}
